Fix font size when gdk_x11_display_set_window_scale() is used
authorOwen W. Taylor <otaylor@fishsoup.net>
Wed, 5 Mar 2014 20:42:38 +0000 (15:42 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 7 Mar 2014 04:20:00 +0000 (23:20 -0500)
We have a hack in the XSETTINGS code to substitute gtk-xft-dpi
with gdk-unscaled-dpi unless the screen has a fixed window scale,
in which case we just use gtk-xft-dpi.

But if the screen is changed to have a fixed window scale, then
the substituted value of gdk-unscaled-dpi will stick around until
the next (coincidental) change to XSETTINGS. To fix this, force
an immediate reread of the XSETTINGS property when
gdk_x11_display_set_window_scale() is used.

https://bugzilla.gnome.org/show_bug.cgi?id=725754

gdk/x11/gdkdisplay-x11.c
gdk/x11/xsettings-client.c
gdk/x11/xsettings-client.h

index 1ba463584778a911af8adce0757720e9549d8ac4..5e7ae7525324ff6c24e4cdfdd8940c86f78b952f 100644 (file)
@@ -2697,6 +2697,7 @@ gdk_x11_display_set_window_scale (GdkDisplay *display,
                                   gint scale)
 {
   GdkX11Screen *x11_screen;
+  gboolean need_reread_settings = FALSE;
 
   g_return_if_fail (GDK_IS_X11_DISPLAY (display));
 
@@ -2709,8 +2710,19 @@ gdk_x11_display_set_window_scale (GdkDisplay *display,
 
   x11_screen = GDK_X11_SCREEN (GDK_X11_DISPLAY (display)->screen);
 
-  x11_screen->fixed_window_scale = TRUE;
+  if (!x11_screen->fixed_window_scale)
+    {
+      x11_screen->fixed_window_scale = TRUE;
+
+      /* We treat screens with a window scale set differently when
+       * reading xsettings, so we need to reread */
+      need_reread_settings = TRUE;
+    }
+
   _gdk_x11_screen_set_window_scale (x11_screen, scale);
+
+  if (need_reread_settings)
+    _gdk_x11_settings_force_reread (x11_screen);
 }
 
 
index e6279b904e35eab51934f15e52982e8cf4a9d189..87b4addbea4adef2ec1c120866cfdc14093f22c7 100644 (file)
@@ -581,6 +581,12 @@ _gdk_x11_xsettings_init (GdkX11Screen *x11_screen)
   check_manager_window (x11_screen, FALSE);
 }
 
+void
+_gdk_x11_settings_force_reread (GdkX11Screen *x11_screen)
+{
+  read_settings (x11_screen, TRUE);
+}
+
 void
 _gdk_x11_xsettings_finish (GdkX11Screen *x11_screen)
 {
index 9ae149e298ba73fb4bdb289bc6a3500f347f2c56..89adc7d1afdb21afc0e6e1f27a3227cea4a48946 100644 (file)
@@ -27,5 +27,6 @@
 
 void _gdk_x11_xsettings_init            (GdkX11Screen        *x11_screen);
 void _gdk_x11_xsettings_finish          (GdkX11Screen        *x11_screen);
+void _gdk_x11_settings_force_reread     (GdkX11Screen        *x11_screen);
 
 #endif /* XSETTINGS_CLIENT_H */